#include <iostream>
using namespace std;
typedef long long LL;
typedef long long ll;
const LL N = 1e6 + 10;

ll n, m;

ll a[N];

LL cala(LL mid)
{
    LL num = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] > mid)
            num += (a[i] - mid);

    }
    return num;
}

int main()
{
    cin >> n >> m;
    ll max = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if (a[i] > max)
        {
            max = a[i];
        }
    }

    LL right=max+10;
    LL left=0;

    LL mid;
    while (right>left)
    {

        mid = (right + left+1) / 2;
        if (cala(mid) < m)
        {
            right=mid-1;
        }
        else
        {
            left = mid;
        }

    }

    cout << left << endl;

    return 0;
}
